home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Raten1.cpp < prev    next >
C/C++ Source or Header  |  1998-12-13  |  1KB  |  30 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Raten1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. int Eingabe, Zufall;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.     : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Button1Click(TObject *Sender)
  17. {
  18.   Edit1->SetFocus ();
  19.   Eingabe = StrToInt (Edit1->Text);
  20.   if (Eingabe == Zufall) Label1->Caption = "Richtig geraten!";
  21.   if (Eingabe < Zufall) Label1->Caption = "Deine Zahl ist zu klein!";
  22.   if (Eingabe > Zufall) Label1->Caption = "Deine Zahl ist zu gro▀!";
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TForm1::FormCreate(TObject *Sender)
  26. {
  27.   randomize ();
  28.   Zufall = random (1000) + 1;
  29. }
  30. //---------------------------------------------------------------------------